package nxu.service.impl;

import nxu.dao.UserMapper;
import nxu.entity.User;
import nxu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    /**
     * 用户注册
     *
     * @param user 用户
     * @return 注册结果(0 : 失败, 1 : 成功)
     */
    @Override
    public int userRegister(User user) {
        return userMapper.insertUser(user);
    }

    /**
     * 用户登录
     *
     * @param phone    用户名
     * @param password 密码
     * @return 登录结果(null : 失败, User : 成功)
     */
    @Override
    public User userLogin(String phone, String password) {
        return userMapper.selectUser(phone, password);
    }
}
